import unittest
import ddt
from InterfaceTest.common.ExcelUtil import ExcelUtil
# from HTMLTestReportCN import HTMLTestRunner
#from InterfaceTest.common.HTMLTestRunner_PY3 import HTMLTestRunner
from InterfaceTest.common.HTMLTestRunner_2 import HTMLTestRunner
import datetime
# excel = ExcelUtil('../data/test.xlsx', 'Sheet1')
excel = ExcelUtil('./data/test.xlsx', 'Sheet1')


@ddt.ddt
class DataTest(unittest.TestCase):
    #def setUp(self):
    #    print('start')

    #def tearDown(self):
    #    print('stop')
    i = 2

    @unittest.skipIf(i == 2, reason='asssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdwadwadadwadadwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
    def test_aa(self):
        print('aa')

    @ddt.data(*excel.next())
    def test_Login(self, data):
        #print("==test==")
        print(data['动作'])
        #print(data['端口'])
        #print(data['地址'])

    @unittest.skipIf(i == 2, reason='s')
    def test_ss(self):
        print('test_ss')
    
    def test_upper(self):
        self.assertEqual('foo'.upper(), 'fOO')


class DaTa2Test(unittest.TestCase):
    i = 1

    @unittest.skipIf(i == 2, reason='dd')
    def test_dd(self):
        print('测试_dd')

    @unittest.skipIf(i == 1, reason='cc')
    def test_cc(self):
        print('测试_cc')


if __name__ == "__main__":
    now = datetime.datetime.now().strftime("%Y-%m-%d %H_%M_%S")

    #suite = unittest.TestLoader().loadTestsFromTestCase(DataTest)
    # suite = unittest.TestLoader().
    # unittest.TextTestRunner(verbosity=2).run(suite)
    suite1 = unittest.TestSuite(tests=[DataTest('test_upper'), DaTa2Test('test_dd')])
    filePath = now + "Result.html"
    print(filePath)
    fp = open(filePath, 'wb')
    # 生成报告的Title,描述
    #runner = HTMLTestReportCN.HTMLTestRunner(stream=fp)
    runner = HTMLTestRunner(stream=fp)
    runner.run(suite1)
